package com.cooper.scraper.show;

import com.cooper.android.comm.Resource;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public abstract class FanartAdapter<T extends Resource> extends BaseAdapter {
	
	protected FanartsShow<T> fanartsShow;
	
	protected AdapterDataChangedListener dataChangedListener;

	public FanartsShow<T> getFanartViewAdapter() {
		return fanartsShow;
	}

	public void setFanartsShow(FanartsShow<T> fanartsShow) {
		this.fanartsShow = fanartsShow;
	}

	public abstract void destroy();
	
	public abstract void refresh();
	
	protected abstract T getResource(int position);
	
	protected void onShowView(T resource, int position){
	}

	public void setDataChangedListener(AdapterDataChangedListener dataChangedListener) {
		this.dataChangedListener = dataChangedListener;
	}
	
	@Override
	public final View getView(int position, View convertView, ViewGroup parent) {
		T resource = getResource(position);
		onShowView(resource,position);
		return fanartsShow.getResourceView(resource, convertView,
				parent);
	}
	

}
